package com.wedo.search.controller;

import com.wedo.common.pojo.PageResult;
import com.wedo.search.pojo.BookSearchRequest;
import com.wedo.search.pojo.SearchBook;
import com.wedo.search.service.SearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

@Controller
public class SearchController {

    @Autowired
    private SearchService searchService;

    @PostMapping("/page")
    public ResponseEntity<PageResult<SearchBook>> search(@RequestBody BookSearchRequest request) {
        PageResult<SearchBook> result = this.searchService.search(request);
        return ResponseEntity.ok(result);
    }
}
